/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.servitware.cr.crdoc.sincro;

import com.servitware.cardio.InformeManager;
import com.servitware.cardio.config.Configuratio;
import com.servitware.cardio.domain.transport.SolicitudTx;
import com.servitware.cardio.transport.CardioWebApp;
import java.util.Date;
import org.apache.log4j.Logger;
import com.servitware.util.TimeUtil;
import javax.swing.JTextField;

/**
 *
 * @author erik
 */
public class SynchroInforme extends Thread
{

    private static final Logger logger = Logger.getLogger(SynchroInforme.class);
    private SolicitudTx solicitudTx = null;
    private InformeManager infManager = null;
    private JTextField reportTo;

    /**
     * Constructor
     * <p>
     * @param solicitudTx
     * @param cfg
     * @param reportTo
     */
    public SynchroInforme(SolicitudTx solicitudTx, Configuratio cfg, JTextField reportTo)
    {
        this.solicitudTx = solicitudTx;
        
        this.infManager = new InformeManager(solicitudTx, cfg );
        this.reportTo = reportTo;

        logger.info("SynchroInforme: inicializado!");
    }

    @Override
    public void run()
    {

        Date date = new Date();

        logger.info("SynchroInforme: Corriendo ->" + date.toString());

        infManager.informar();

        reportTo.setText("Inf- " + solicitudTx.getId() + " -> " + TimeUtil.getHHMM(date));

        logger.info("SynchroInforme: terminado!");

    }

}
